<?
$sub_menu = "230300";
include_once("./_common.php");

auth_check($auth[$sub_menu], "w");

$g4[title] = $html_title;
include_once("$g4[admin_path]/admin.head.php");

$token = get_token();

$html_title = "무통장 입금통보";
if ($w == "") 
{
    $html_title .= " 등록";
    $attr = "";
} 
else if ($w == "u") 
{
    $html_title .= " 수정";
    $row = sql_fetch("select * from $mw_cash[account_table] where ac_id = '$ac_id'");

    if ($row[ac_paydate] == "0000-00-00")
	$row[ac_paydate] = $g4[time_ymd];

    $attr = "readonly style='background-color:#efefef'";
} 
else
    alert("제대로 된 값이 넘어오지 않았습니다.");
?>

<link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js"></script>

<?
//==============================================================================
// jquery date picker
//------------------------------------------------------------------------------
// 참고) ie 에서는 년, 월 select box 를 두번씩 클릭해야 하는 오류가 있습니다.
//------------------------------------------------------------------------------
// jquery-ui.css 의 테마를 변경해서 사용할 수 있습니다.
// base, black-tie, blitzer, cupertino, dark-hive, dot-luv, eggplant, excite-bike, flick, hot-sneaks, humanity, le-frog, mint-choc, overcast, pepper-grinder, redmond, smoothness, south-street, start, sunny, swanky-purse, trontastic, ui-darkness, ui-lightness, vader
// 아래 css 는 date picker 의 화면을 맞추는 코드입니다.
?>
<style type="text/css">
<!--
.ui-datepicker { font:12px dotum; }
.ui-datepicker select.ui-datepicker-month, 
.ui-datepicker select.ui-datepicker-year { width: 70px;}
.ui-datepicker-trigger { margin:0 0 -5px 2px; }
-->
</style>
<script type="text/javascript">
/* Korean initialisation for the jQuery calendar extension. */
/* Written by DaeKwon Kang (ncrash.dk@gmail.com). */
jQuery(function($){
        $.datepicker.regional['ko'] = {
                closeText: '닫기',
                prevText: '이전달',
                nextText: '다음달',
                currentText: '오늘',
                monthNames: ['1월(JAN)','2월(FEB)','3월(MAR)','4월(APR)','5월(MAY)','6월(JUN)',
                '7월(JUL)','8월(AUG)','9월(SEP)','10월(OCT)','11월(NOV)','12월(DEC)'],
                monthNamesShort: ['1월','2월','3월','4월','5월','6월',
                '7월','8월','9월','10월','11월','12월'],
                dayNames: ['일','월','화','수','목','금','토'],
                dayNamesShort: ['일','월','화','수','목','금','토'],
                dayNamesMin: ['일','월','화','수','목','금','토'],
                weekHeader: 'Wk',
                dateFormat: 'yy-mm-dd',
                firstDay: 0,
                isRTL: false,
                showMonthAfterYear: true,
                yearSuffix: ''};
        $.datepicker.setDefaults($.datepicker.regional['ko']);

    $('#ac_paydate').datepicker({
        showOn: 'button',
        buttonImage: '<?=$g4[path]?>/img/calendar.gif',
        buttonImageOnly: true,
        buttonText: "달력",
        changeMonth: true,
        changeYear: true,
        showButtonPanel: true,
        yearRange: 'c-99:c+99'
    }); 
});
</script>
<?
//==============================================================================
?>

<form name=fwrite method=post action="mw.account.update.php" autocomplete="off">
<input type=hidden name=w     value='<?=$w?>'>
<input type=hidden name=sfl   value='<?=$sfl?>'>
<input type=hidden name=stx   value='<?=$stx?>'>
<input type=hidden name=sst   value='<?=$sst?>'>
<input type=hidden name=sod   value='<?=$sod?>'>
<input type=hidden name=page  value='<?=$page?>'>
<input type=hidden name=token value='<?=$token?>'>
<input type=hidden name=ac_id value='<?=$ac_id?>'>
<table width=100% cellpadding=0 cellspacing=0>
<colgroup width=30% class='col1 pad1 bold right'>
<colgroup width=70% class='col2 pad2'>
<tr class='ht'>
    <td colspan=4 class=title align=left><img src='<?=$g4[admin_path]?>/img/icon_title.gif'> <?=$html_title?></td>
</tr>
<tr><td colspan=4 class='line1'></td></tr>
<tr class='ht'>
    <td width="30%" class='col1 pad1 bold right'>회원ID</td>
    <td>
        <? if ($w == '') { ?>
	<input type="text" size="15" name="mb_id" class="ed" required itemname="회원ID" value="<?=$row[mb_id]?>">
        <? } else {
            $mb = get_member($row['mb_id'], "mb_id, mb_name, mb_nick, mb_email, mb_homepage");
            echo get_sideview($mb[mb_id], $mb[mb_nick], $mb[mb_email], $mb[mb_homepage]);
        } ?>
        <!-- <input type="button" class="btn1" value="쪽지 보내기" onclick="win_memo('<?=$g4[bbs_path]?>/memo_form.php?me_recv_mb_id='+fwrite.mb_id.value);"> -->
    </td>
</tr>
<tr class='ht'>
    <td class='col1 pad1 bold right'>입금자명</td>
    <td>
	<input type="text" size="15" name="ac_name" class="ed" required itemname="입금자명" value="<?=$row[ac_name]?>">
    </td>
</tr>
<tr class='ht'>
    <td class='col1 pad1 bold right'>핸드폰 번호</td>
    <td>
	<input type="text" size="15" name="ac_hp" class="ed" telnumber itemname="핸드폰번호" value="<?=$row[ac_hp]?>">
	<? if ($w == "u") { ?>
	<input type="button" class="btn1" value="입금확인 문자전송" onclick="sms_ok()">
	<? } ?>
    </td>
</tr>
<tr class='ht'>
    <td class='col1 pad1 bold right'>IP</td>
    <td> <?=$row[ac_ip]?> </td>
</tr>
<tr class='ht'>
    <td class='col1 pad1 bold right'>AGENT</td>
    <td> <div title="<?=$row[ac_agent]?>"><?=cut_str($row[ac_agent], 80)?></div> </td>
</tr>
<? if ($w == "u") { ?>
<tr class='ht'>
    <td class='col1 pad1 bold right'>충전해야 할 <?=$mw_cash[cf_cash_name]?></td>
    <td>
	<?=number_format(mw_payment_to_cash($row[ac_payment], $row[ac_tax]))?> <?=$mw_cash[cf_cash_unit]?>
    </td>
</tr>
<? } ?>
<tr class='ht'>
    <td class='col1 pad1 bold right'>부가세</td>
    <td>
	<?
	if ($w == "")
	    if ($mw_cash[cf_tax]) echo "부가세 별도"; else echo "부가세 포함";
	else
	    if ($row[ac_tax]) echo "부가세 별도"; else echo "부가세 포함";
	?>
    </td>
</tr>
<tr class='ht'>
    <td class='col1 pad1 bold right'>입금액</td>
    <td>
	<input type="text" size="15" name="ac_payment" class="ed" required numeric itemname="입금액" value="<?=$row[ac_payment]?>"> 원
	<? if ($w == "u") { ?>
	<input type="button" class="btn1" value="<?=$mw_cash[cf_cash_name]?> 자동충전" onclick="account_to_cash()">
	<? } ?>
    </td>
</tr>
<tr class='ht'>
    <td class='col1 pad1 bold right'>입금일자</td>
    <td>
        <input type="text" size="15" maxlength="10" id="ac_paydate" name="ac_paydate" value="<?=$row[ac_paydate]?>" itemname="입금일자" class="ed"> 
        <!--<a href="javascript:win_calendar('ac_paydate', document.fwrite.ac_paydate, '-');"><img src="img/calendar.gif" border=0 align=absmiddle title='달력 - 날짜를 선택하세요'></a>-->
    </td>
</tr>
<tr class='ht'>
    <td class='col1 pad1 bold right'>상태</td>
    <td>
	<select name="ac_status" required itemname="상태">
	<option value="입금신청">입금신청</option>
	<option value="충전완료">충전완료</option>
	<option value="취소">취소</option>
	</select>
	<script type="text/javascript">fwrite.ac_status.value = "<?=$row[ac_status]?>";</script>
    </td>
</tr>
<tr class='ht'>
    <td class='col1 pad1 bold right'>입금자 메모</td>
    <td>
    <? if ($attr) $attr = str_replace("style='", "style='width:100%; height:100px; ", $attr); ?>
    <textarea name="ac_memo" class="ed" itemname="입금자 메모" <?=$attr?> style="width:100%; height:100px;"><?=$row[ac_memo]?></textarea> </td>
</tr>
<tr class='ht'>
    <td class='col1 pad1 bold right'>관리자 메모</td>
    <td> <textarea style="width:100%; height:100px;" name="ac_admin_memo" class="ed" itemname="관리자메모"><?=$row[ac_admin_memo]?></textarea> </td>
</tr>
<? if ($w == "u") { ?>
<tr class='ht'>
    <td class='col1 pad1 bold right'>일시</td>
    <td> <?=$row[ac_datetime]?> </td>
</tr>
<? } ?> 
<tr><td colspan=4 class='line2'></td></tr>
</table>

<p align=center>
    <input type=submit class=btn1 accesskey='s' value='  확  인  '>&nbsp;
    <input type=button class=btn1 value='  목  록  ' onclick="document.location.href='mw.account.list.php?<?=$qstr?>';">
</form>

<script type="text/javascript">
function account_to_cash() {
    if(confirm("<?=$row[mb_id]?> 회원에게 <?=$mw_cash[cf_cash_name]?> <?=mw_payment_to_cash($row[ac_payment], $row[ac_tax])?> <?=$mw_cash[cf_cash_unit]?> 충전 하시겠습니까?"))
	location.href = "mw.account.update.php?w=c&ac_id=<?=$ac_id?><?=$qstr?>";
}

function sms_ok() {
    win_open('sms/sms_form.php?ac_id=<?=$ac_id?>', 'sms', 'width=300,height=300');
    
}
</script>

<?
include_once ("$g4[admin_path]/admin.tail.php");
?>
